﻿using System;
using SweeperPrototype.Business.Fields;

namespace SweeperPrototype.Objects
{
    public partial class ExposureMappingSubscription
    {
        public class UniqueKey
        {
            private readonly ExposureRIC m_ExposureRIC;
            private readonly EffectiveRIC m_EffectiveRIC;

            public UniqueKey(ExposureRIC exposure_ric, EffectiveRIC effective_ric)
            {
                m_ExposureRIC = exposure_ric;
                m_EffectiveRIC = effective_ric;
            }

            public static bool operator ==(UniqueKey lhs, UniqueKey rhs)
            {
                if (ReferenceEquals(null, lhs)) return false;
                if (ReferenceEquals(null, rhs)) return false;

                return lhs.Equals(rhs);
            }

            public static bool operator !=(UniqueKey lhs, UniqueKey rhs)
            {
                return !(lhs == rhs);
            }

            public bool Equals(UniqueKey other)
            {
                if (ReferenceEquals(null, other)) return false;
                if (ReferenceEquals(this, other)) return true;
                return Equals(other.m_ExposureRIC, m_ExposureRIC) && Equals(other.m_EffectiveRIC, m_EffectiveRIC);
            }

            public override bool Equals(object obj)
            {
                if (ReferenceEquals(null, obj)) return false;
                if (ReferenceEquals(this, obj)) return true;
                if (obj.GetType() != typeof(UniqueKey)) return false;
                return Equals((UniqueKey)obj);
            }

            public override int GetHashCode()
            {
                unchecked
                {
                    return ((m_ExposureRIC != null ? m_ExposureRIC.GetHashCode() : 0) * 397) ^ (m_EffectiveRIC != null ? m_EffectiveRIC.GetHashCode() : 0);
                }
            }
        }
    }
}
